VERSION 5.00
Begin VB.Form frmCondicionIva 
   BackColor       =   &H80000013&
   Caption         =   "CondicionIva"
   ClientHeight    =   3435
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   8520
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   3435
   ScaleWidth      =   8520
   Begin VB.Frame Frame1 
      BackColor       =   &H80000013&
      Caption         =   "Condicion Iva"
      Height          =   3015
      Left            =   120
      TabIndex        =   4
      Top             =   120
      Width           =   6015
      Begin VB.CommandButton cmdBuscar 
         Height          =   375
         Left            =   5280
         Picture         =   "frmCondicionIva.frx":0000
         Style           =   1  'Graphical
         TabIndex        =   10
         Top             =   240
         Width           =   495
      End
      Begin VB.TextBox txtAbreviatura 
         Height          =   285
         Left            =   240
         MaxLength       =   10
         TabIndex        =   9
         Top             =   1080
         Width           =   1335
      End
      Begin CtaCte.txtNumero2 txtCodigoAFIP 
         Height          =   375
         Left            =   1680
         TabIndex        =   7
         Top             =   1080
         Width           =   495
         _extentx        =   873
         _extenty        =   661
      End
      Begin CtaCte.txtNumero2 txtCodigo 
         Height          =   255
         Left            =   240
         TabIndex        =   6
         Top             =   360
         Width           =   495
         _extentx        =   873
         _extenty        =   450
      End
      Begin VB.TextBox txtDenom 
         Height          =   285
         Left            =   840
         MaxLength       =   50
         TabIndex        =   0
         Top             =   360
         Width           =   4335
      End
      Begin VB.CommandButton cmdGrabar 
         Caption         =   "&Aceptar"
         Height          =   855
         Left            =   1440
         Picture         =   "frmCondicionIva.frx":058A
         Style           =   1  'Graphical
         TabIndex        =   1
         Top             =   1680
         Width           =   1455
      End
      Begin VB.CommandButton cmdCancelar 
         Caption         =   "&Cancelar"
         Height          =   855
         Left            =   3120
         Picture         =   "frmCondicionIva.frx":0894
         Style           =   1  'Graphical
         TabIndex        =   2
         Top             =   1665
         Width           =   1455
      End
      Begin VB.Label Label1 
         BackColor       =   &H80000013&
         Caption         =   "Abreviatura"
         Height          =   255
         Left            =   240
         TabIndex        =   8
         Top             =   840
         Width           =   975
      End
      Begin VB.Label Codigo 
         BackColor       =   &H80000013&
         Caption         =   "Codigo AFIP"
         Height          =   255
         Left            =   1680
         TabIndex        =   5
         Top             =   840
         Width           =   1215
      End
   End
   Begin VB.CommandButton cmdSalir 
      Caption         =   "Ce&rrar"
      Height          =   855
      Left            =   6720
      Picture         =   "frmCondicionIva.frx":0B9E
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   720
      Width           =   1455
   End
End
Attribute VB_Name = "frmCondicionIva"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim esNuevo As Boolean
Dim sql, codigoafip As String


Private Sub cmdBuscar_Click()
dlgConsulta.consulta = "SELECT id_condiva, denominacion FROM condicioniva"
dlgConsulta.set_titulo ("Condicion IVA")
dlgConsulta.Show vbModal
If Not dlgConsulta.Codigo = 0 Then
    txtCodigo.settext Str(dlgConsulta.Codigo)
    txtCodigo_Validado
End If

End Sub

Private Sub cmdCancelar_Click()
habilitar False
limpiar
End Sub

Private Sub cmdGrabar_Click()
If Not txtCodigo.text = "" Or txtDenom.text = "" Or txtAbreviatura.text = "" Then
If txtCodigoAFIP.text = "" Then
    codigoafip = "NULL"
Else
    codigoafip = Str(txtCodigoAFIP.text)
End If

If esNuevo Then
    sql = "INSERT INTO condicioniva (id_condiva, denominacion, abreviatura, iva_codigoafip) VALUES ( "
    sql = sql & Str(txtCodigo.text) & ", '" & txtDenom.text & "', '" & txtAbreviatura.text & "', " & codigoafip & " ) "
    cn.Execute sql
Else
    sql = "UPDATE condicioniva SET denominacion = '" & txtDenom.text
    sql = sql & "', abreviatura = '" & txtAbreviatura.text
    sql = sql & "', iva_codigoafip = " & codigoafip
    sql = sql & " WHERE id_condiva = " & Str(txtCodigo.text)
    cn.Execute sql
End If
habilitar False
limpiar
End If

End Sub
Sub limpiar()
txtCodigo.settext ""
txtDenom.text = ""
txtCodigoAFIP.settext ""
txtAbreviatura.text = ""
End Sub
Private Sub cmdSalir_Click()
Unload Me
End Sub

Private Sub Form_Load()
habilitar False
Me.Height = 3945
Me.Width = 8640
End Sub

Private Sub txtCodigo_Validado()
If Not txtCodigo.text = "" Then
ConsultaSql "SELECT id_condiva, denominacion, abreviatura, iva_codigoafip FROM condicioniva WHERE id_condiva = " & Str(txtCodigo.text)
If rs.RecordCount = 0 Then
    esNuevo = True
    txtDenom.text = ""
    txtCodigoAFIP.settext ""
    txtAbreviatura.text = ""
Else
    rs.MoveFirst
    txtDenom.text = rs!denominacion
    txtAbreviatura.text = rs!abreviatura
    txtCodigoAFIP.settext "" & rs!iva_codigoafip
    esNuevo = False
End If
habilitar True
End If
End Sub

Sub habilitar(b As Boolean)
txtDenom.Enabled = b
txtCodigo.habilitar Not b
cmdGrabar.Enabled = b
txtCodigoAFIP.habilitar b
txtAbreviatura.Enabled = b
cmdCancelar.Enabled = b
End Sub
